import { GLabel } from "../../../../../com/mui/controls/GLabel";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { DataEvent } from "../../../events/DataEvent";
import { EquipmentModuleConst } from "../data/EquipmentModuleConst";
import { ItemData } from "../../../resource/info/ItemData";
import { EItemUpdateOper } from "../../../../../Message/Game/EItemUpdateOper";
import { EItemUpdateType } from "../../../../../Message/Game/EItemUpdateType";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { EquipmentItemDataUtil } from "../../common/EquipmentItemDataUtil";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Vector } from "../../../../../__AS3__/vec/Vector";
type int = number;
//class AttributeConfirmPanel
    
    export  class AttributeConfirmPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._labelsVec = new Vector.<GLabel>();
            this._valuesVec = new Vector.<GLabel>();
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=0;
            var loc4=null;
            ObjCreate.createBg(0, 0, 144, 125, this);
            ObjCreate.createLabel(Language.getString(60274), 0, 2, 144, 20, flash.text.TextFormatAlign.CENTER, this, true, 16702014);
            this._labelsVec.push(this._label1);
            this._labelsVec.push(this._label2);
            this._labelsVec.push(this._label3);
            this._labelsVec.push(this._label4);
            this._labelsVec.push(this._label5);
            this._labelsVec.push(this._label6);
            this._valuesVec.push(this._value1);
            this._valuesVec.push(this._value2);
            this._valuesVec.push(this._value3);
            this._valuesVec.push(this._value4);
            this._valuesVec.push(this._value5);
            this._valuesVec.push(this._value6);
            loc1 = 0;
            while (loc1 < this._labelsVec.length) 
            {
                loc2 = 13;
                loc3 = 21 + loc1 * 17;
                this._labelsVec[loc1] = ObjCreate.createLabel("", loc2, loc3, 55, 20, flash.text.TextFormatAlign.LEFT, this, true, 16702014);
                ++loc1;
            }
            loc1 = 0;
            while (loc1 < this._valuesVec.length) 
            {
                loc2 = 72;
                loc3 = 21 + loc1 * 17;
                this._valuesVec[loc1] = ObjCreate.createLabel("", loc2, loc3, 80, 20, flash.text.TextFormatAlign.LEFT, this, true, 16702014);
                ++loc1;
            }
            return;
        }

        /* internal  */onAttriConfirmClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_AttributeConfirm, null));
            return;
        }

        public setUpdateType(arg1: int, arg2: int, arg3: ItemData): void
        {
            var loc1=0;
            if (!arg3) 
            {
                this._descLabel1.htmlText = "";
                this._descLabel2.htmlText = "";
                return;
            }
            var loc2=arg1;
            switch (loc2) 
            {
                case EItemUpdateOper._EItemUpdateOperStrengthen:
                {
                    loc1 = arg3.itemExInfo.strengthen;
                    if (arg2 != EItemUpdateType._EItemUpdateUpgrade) 
                    {
                        if (arg2 == EItemUpdateType._EItemUpdateRefresh) 
                        {
                            this._descLabel1.htmlText = Language.getString(60278) + HTMLUtil.addColor(arg3.itemExInfo.perfectStrengthen + "%", "#F1FFB1");
                            this._descLabel2.htmlText = Language.getString(60279) + HTMLUtil.addColor(arg3.itemExInfo.currentStrengthen + "%", "#F1FFB1");
                        }
                    }
                    else if (loc1 != 10) 
                    {
                        this._descLabel1.htmlText = Language.getStringByParam(60276, loc1 + 1);
                        this._descLabel2.htmlText = Language.getString(60277);
                    }
                    else 
                    {
                        this._descLabel1.htmlText = Language.getString(60275);
                        this._descLabel2.htmlText = "";
                    }
                    break;
                }
                case EItemUpdateOper._EItemUpdateOperRefine:
                {
                    loc1 = arg3.itemExInfo.refine;
                    if (arg2 != EItemUpdateType._EItemUpdateUpgrade) 
                    {
                        if (arg2 == EItemUpdateType._EItemUpdateRefresh) 
                        {
                            this._descLabel1.htmlText = Language.getString(60283) + HTMLUtil.addColor(arg3.itemExInfo.perfectRefine + "%", "#F1FFB1");
                            this._descLabel2.htmlText = Language.getString(60284) + HTMLUtil.addColor(arg3.itemExInfo.currentRefine + "%", "#F1FFB1");
                        }
                    }
                    else if (loc1 != 10) 
                    {
                        this._descLabel1.htmlText = Language.getStringByParam(60281, loc1 + 1);
                        this._descLabel2.htmlText = Language.getString(60282);
                    }
                    else 
                    {
                        this._descLabel1.htmlText = Language.getString(60280);
                        this._descLabel2.htmlText = "";
                    }
                    break;
                }
            }
            return;
        }

        public setBaseAttribute(arg1: ItemData): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=null;
            this.clearLabels();
            if (arg1) 
            {
                loc1 = new EquipmentItemDataUtil(arg1);
                loc2 = loc1.getBasePropArray();
                loc3 = 0;
                while (loc3 < loc2.length) 
                {
                    loc4 = loc2[loc3] as Map<any, any> /* flash.utils.Dictionary */;
                    this._labelsVec[loc3].htmlText = loc4["name"];
                    if (this._operationId != EItemUpdateOper._EItemUpdateOperPetEquipStrengthen) 
                    {
                        this._valuesVec[loc3].htmlText = this.getValueString(loc4["value"]) + "+" + loc1.getBaseAdditive(loc4["value"]);
                    }
                    else 
                    {
                        this._valuesVec[loc3].htmlText = int(this.getValueString(loc4["value"])) + loc1.getPetEquipStarAddValue(loc4["type"]) + "+" + loc1.getBaseAdditive(loc4["baseValue"]);
                    }
                    ++loc3;
                }
            }
            return;
        }

        public set operationId(arg1: int)
        {
            this._operationId = arg1;
            return;
        }

        /* internal  */getValueString(arg1: int): string
        {
            var loc1="";
            loc1 = loc1 + arg1;
            if (arg1 < 10) 
            {
                loc1 = loc1 + "     ";
            }
            else if (arg1 < 100) 
            {
                loc1 = loc1 + "    ";
            }
            else if (arg1 < 1000) 
            {
                loc1 = loc1 + "   ";
            }
            else 
            {
                loc1 = loc1 + "  ";
            }
            return loc1;
        }

        /* internal  */clearLabels(): void
        {
            var loc1=0;
            loc1 = 0;
            while (loc1 < this._labelsVec.length) 
            {
                this._labelsVec[loc1].htmlText = "";
                this._valuesVec[loc1].htmlText = "";
                ++loc1;
            }
            return;
        }

        public valueGlow(): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._labelsVec;
            for(loc1 of loc3) 
            {
                EffectManager.glowFilterReg(loc1, [FilterConst.taskShowTargetFilter], 0.6, 10, 5, 3);
            }
            loc2 = 0;
            loc3 = this._valuesVec;
            for(loc1 of loc3) 
            {
                EffectManager.glowFilterReg(loc1, [FilterConst.taskShowTargetFilter], 0.6, 10, 5, 3);
            }
            return;
        }

        /* internal */ /* var */_operationId: int=1;

        /* internal */ /* var */_descLabel1: GLabel;

        /* internal */ /* var */_descLabel2: GLabel;

        /* internal */ /* var */_labelsVec: Vector.<GLabel>;

        /* internal */ /* var */_valuesVec: Vector.<GLabel>;

        /* internal */ /* var */_label1: GLabel;

        /* internal */ /* var */_label2: GLabel;

        /* internal */ /* var */_label3: GLabel;

        /* internal */ /* var */_label4: GLabel;

        /* internal */ /* var */_label5: GLabel;

        /* internal */ /* var */_label6: GLabel;

        /* internal */ /* var */_value1: GLabel;

        /* internal */ /* var */_value2: GLabel;

        /* internal */ /* var */_value3: GLabel;

        /* internal */ /* var */_value4: GLabel;

        /* internal */ /* var */_value5: GLabel;

        /* internal */ /* var */_value6: GLabel;

        /* internal */ /* var */_attriConfirmBtn: GButton;
    }
